<template>
  <h2>toRef的使用以及特点:</h2>
  <h3>state:{{ state }}</h3>
  <h3>age:{{ age }}</h3>
  <h3>money:{{ money }}</h3>
  <Child :age="age" />
  <button @click="update">更新数据</button>
</template>

<script lang="ts">
import { defineComponent, reactive, toRef, ref } from 'vue'
import Child from './components/Child.vue'
// interface UserInfo<T> {
//   age: T
//   money: T
// }
export default defineComponent({
  name: 'App',
  components: { Child },
  setup() {
    const state = reactive({
      age: 5,
      money: 10
    })
    let age = toRef(state, 'age')
    let money = ref(state.money)
    const update = () => {
      age.value += 10
      money.value += 10
    }
    return {
      state,
      age,
      money,
      update
    }
  }
})
</script>

<style scoped>
</style>